package com.tt.fashionWebSite.controller;

import com.tt.fashionWebSite.dto.*;
import com.tt.fashionWebSite.service.Ad_OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
public class Ad_OrderController {
    @Autowired
    private Ad_OrderService ad_orderService;

    @SuppressWarnings("rawtypes")
    @RequestMapping(value = "/admin/header/adOrderCommon", method = RequestMethod.POST)
    public @ResponseBody
    JsonResponseDto<Integer> adminOrder(HttpServletRequest request, @RequestBody DatHangDto orderDto) {
        return new JsonResponseDto<Integer>(ad_orderService.adminOrder(orderDto));
    }

    @SuppressWarnings("rawtypes")
    @RequestMapping(value = "/admin/getOrderCommon", method = RequestMethod.GET)
    public @ResponseBody
    JsonResponseDto<List<DatHangDto>> getOrderCommon(HttpServletRequest request) {
        return new JsonResponseDto<List<DatHangDto>>(ad_orderService.getOrderCommon(), JsonResponseCode.SUCCESS);
    }

    @SuppressWarnings("rawtypes")
    @RequestMapping(value = "/admin/getOrderDetailCommon", method = RequestMethod.GET)
    public @ResponseBody
    JsonResponseDto<List<ChiTietDatHangDto>> getOrderDetailCommon(HttpServletRequest request) {
        return new JsonResponseDto<List<ChiTietDatHangDto>>(ad_orderService.getOrderDetailCommon(), JsonResponseCode.SUCCESS);
    }

    @SuppressWarnings("rawtypes")
    @RequestMapping(value = "/admin/getAllMember", method = RequestMethod.GET)
    public @ResponseBody
    JsonResponseDto<List<ThongTinThanhVienDto>> getMemberInfor(HttpServletRequest request) {
        return new JsonResponseDto<List<ThongTinThanhVienDto>>(ad_orderService.getMemberInfor(), JsonResponseCode.SUCCESS);
    }

    @SuppressWarnings("rawtypes")
    @RequestMapping(value = "/admin/getAllOrderCode", method = RequestMethod.GET)
    public @ResponseBody
    JsonResponseDto<List<DatHangDto>> getAllOrderCode(HttpServletRequest request) {
        return new JsonResponseDto<List<DatHangDto>>(ad_orderService.getOrderCommon(), JsonResponseCode.SUCCESS);
    }

    @SuppressWarnings("rawtypes")
    @RequestMapping(value = "/admin/getAllProductDetailCode", method = RequestMethod.GET)
    public @ResponseBody
    JsonResponseDto<List<ChiTietSanPhamDto>> getAllProductDetailCode(HttpServletRequest request) {
        return new JsonResponseDto<List<ChiTietSanPhamDto>>(ad_orderService.getAllProductDetailCode(), JsonResponseCode.SUCCESS);
    }
}